package com.taotao.portal.service.impl;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.taotao.common.HttpClientUtil;
import com.taotao.common.TaotaoResult;
import com.taotao.pojo.TbUser;
import com.taotao.portal.service.UserService;
@Service
public class UserServiceImpl implements UserService {
	@Value("${SSO_BASE_URL}")
	public String SSO_BASE_URL;
	@Value("${SSO_DOMAIN_URL}")
	public String SSO_DOMAIN_URL;
	@Value("${SSO_USER_TOKEN}")
	public String SSO_USER_TOKEN;
	@Value("${SSO_USER_PAGE}")
	public String SSO_USER_PAGE;
	@Override
	public TbUser getUserByToken(String token) {
		try {
			String json=HttpClientUtil.doGet(SSO_BASE_URL+SSO_USER_TOKEN+token);
			TaotaoResult result=TaotaoResult.formatToPojo(json, TbUser.class);
			if(result.getStatus()==200){
				return (TbUser) result.getData();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
